/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('nbftestpop', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model MutilComplexRequest {
  arg0?: string(name='arg0'),
  arg1?: int32(name='arg1'),
  arg2?: {
    stringValue?: string(name='stringValue'),
    intValue?: int32(name='intValue'),
    booleanValue?: boolean(name='booleanValue'),
    integerValue?: int32(name='integerValue'),
    longValue?: long(name='longValue'),
    secondInput?: {
      secondString?: string(name='secondString'),
      thirdList?: [ 
        {
          thirdInt?: int32(name='thirdInt'),
          thirdString?: string(name='thirdString'),
        }
      ](name='thirdList'),
      secondInt?: int32(name='secondInt'),
    }(name='secondInput'),
  }(name='arg2'),
}

model MutilComplexShrinkRequest {
  arg0?: string(name='arg0'),
  arg1?: int32(name='arg1'),
  arg2Shrink?: string(name='arg2'),
}

model MutilComplexResponseBody = {
  stringValue?: string(name='stringValue'),
  secondOutput?: {
    thirdList?: [ 
      {
        thirdInt?: int32(name='thirdInt'),
        thirdString?: string(name='thirdString'),
      }
    ](name='thirdList'),
  }(name='secondOutput'),
  intValue?: int32(name='intValue'),
  booleanValue?: boolean(name='booleanValue'),
  integerValue?: int32(name='integerValue'),
  longValue?: long(name='longValue'),
}

model MutilComplexResponse = {
  headers: map[string]string(name='headers'),
  body: MutilComplexResponseBody(name='body'),
}

async function mutilComplexWithOptions(tmpReq: MutilComplexRequest, runtime: Util.RuntimeOptions): MutilComplexResponse {
  Util.validateModel(tmpReq);
  var request = new MutilComplexShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.arg2)) {
    request.arg2Shrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.arg2, 'arg2', 'json');
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('MutilComplex', '2021-08-06_15-12-55-420', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function mutilComplex(request: MutilComplexRequest): MutilComplexResponse {
  var runtime = new Util.RuntimeOptions{};
  return mutilComplexWithOptions(request, runtime);
}

